<?php
require 'emos/init.php';

use Emos\Form;
use Emos\Db;
use Emos\Editor;

session_start();

$db = new Db\MySql;
$db->connect(array('base'=>'emos'));

$pageEnt = new Editor\Entity('structure_page', 'id');
$pageEnt->setTitle('Page');
$pageEnt->addColumn('id');		
$pageEnt->addColumn('title');
$pageEnt->addField('title', 'title', new Form\Text());


$typeEnt = new Editor\Entity('ariel_type', 'type_id');
$typeEnt->setTitle('Type');
$typeEnt->addColumn('type_id');		
$typeEnt->addColumn('hr_id');
$typeEnt->addColumn('type_title');
$typeEnt->addField('hr_id', 'hr_id', new Form\Text());
$typeEnt->addField('ord', 'ord', new Form\Text());
$typeEnt->addField('detail_url', 'detail_url', new Form\Text());
$typeEnt->addField('type_title', 'type_title', new Form\Text());
//$typeEnt->form->elementSet->add('type_descr', 'type_descr', new Form\Textarea());

$groupEnt = new Editor\Entity('ariel_group', 'group_id');
$groupEnt->setTitle('Group');
$groupEnt->addColumn('group_id');		
$groupEnt->addColumn('type_id');		
$groupEnt->addColumn('group_title');
$groupEnt->addField('hr_id', 'hr_id', new Form\Text());
$groupEnt->addField('ord', 'ord', new Form\Text());
$groupEnt->addField('group_title', 'group_title', new Form\Text());
$groupEnt->addField('group_descr', 'group_descr', new Form\Textarea());

$equipEnt = new Editor\Entity('equipment', 'equipment_id');
$equipEnt->setTitle('Equipment');
$equipEnt->addColumn('title');		
$equipEnt->addColumn('subtitle');		
$equipEnt->addField('hr_id', 'hr_id', new Form\Text());
$equipEnt->addField('ord', 'ord', new Form\Text());
$equipEnt->addField('title', 'title', new Form\Text());
$equipEnt->addField('subtitle', 'subtitle', new Form\Text());
$equipEnt->addField('something', 'something', new Form\Text());

$goodsEnt = new Editor\Entity('ariel_goods', 'goods_id');
$goodsEnt->setTitle('Goods');
$goodsEnt->addColumn('goods_title');
$goodsEnt->addField('ord', 'ord', new Form\Text());
$goodsEnt->addField('goods_title', 'goods_title', new Form\Text());
$goodsEnt->addField('goods_hide', 'goods_hide', new Form\Checkbox());
$goodsEnt->addField('goods_prop', 'goods_prop', new Form\Textarea());

//goods_id	group_id	ord	goods_article	goods_title	goods_price	goods_price_hide	goods_prop	goods_hide


$tree = new Editor\Tree();
$tree->setDb($db);

$tree->addEntity($pageEnt);
    $pageEnt->addEntity($pageEnt, 'page_id');
        
$tree->addEntity($typeEnt);
    $typeEnt->addEntity($groupEnt, 'type_id');
        $groupEnt->addEntity($goodsEnt, 'group_id');
    $typeEnt->addEntity($equipEnt, 'type_id');        
$tree->init();
$tree->ajax();



